home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
076-100
/
disk_098
/
thai
/
search.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
1KB
|
73 lines
#include "quiz.h"
struct thai_phrase *
thai_search ( curr , pattern , direction )
struct thai_phrase *curr;
char *pattern;
int direction;
{
if ( curr == NULL )
return ( NULL );
while ( TRUE ) {
curr = ( direction == NEXT_ENTRY ) ? curr->next : curr->prev;
if ( curr == NULL )
return ( NULL );
if ( strcmp ( pattern , curr->thai ) == 0 )
return ( curr );
}
}
struct thai_phrase *
phonetic_search ( curr , pattern , direction )
struct thai_phrase *curr;
char *pattern;
int direction;
{
if ( curr == NULL )
return ( NULL );
while ( TRUE ) {
curr = ( direction == NEXT_ENTRY ) ? curr->next : curr->prev;
if ( curr == NULL )
return ( NULL );
if ( match ( curr->phonetic , pattern ) )
return ( curr );
}
}
struct thai_phrase *
english_search ( curr , pattern , direction )
struct thai_phrase *curr;
char *pattern;
int direction;
{
if ( curr == NULL )
return ( NULL );
while ( TRUE ) {
curr = ( direction == NEXT_ENTRY ) ? curr->next : curr->prev;
if ( curr == NULL )
return ( NULL );
if ( match ( curr->english , pattern ) )
return ( curr );
}
}
match ( buf , pattern )
char *buf , *pattern;
{
register int i , j;
for ( i = 0; buf[i] != '\0'; i++ ) {
for ( j = 0; pattern[j] != '\0'; j++ )
if ( mklower ( buf[i+j] ) != mklower ( pattern[j] ) )
break;
if ( pattern[j] == '\0' )
return ( TRUE );
}
return ( FALSE );
}